<?php

namespace App\Http\Controllers\User;

use App\Http\Controllers\ApiController;
use App\User;
use Illuminate\Http\Request;
use Auth;

class LoginController extends ApiController
{
    //
    public function __invoke(Request $request, User $user)
    {

        if (Auth::attempt($request->only('email', 'password'))) {
            $token = Auth::user()->createToken('auth')->plainTextToken;
            return $token;
        }
        return $this->error('用户名或密码错误');
    }
}
